<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>登陆</title>

        <!-- CSS -->
        <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:400,100,300,500">
        <link rel="stylesheet" href="resources/css/bootstrap.min.css">
        <link rel="stylesheet" href="resources/css/font-awesome.css">
		<link rel="stylesheet" href="resources/css/form-elements.css">
        <link rel="stylesheet" href="resources/css/style.css">
        <link rel="stylesheet" href="resources/css/sweetalert2.css">

    </head>

    <body>
        <!-- Top content -->
        <div class="top-content">
            <div class="inner-bg">
                <div class="container" style="margin-top:70px;">
                    <div class="row">
                        <div class="col-sm-6 col-sm-offset-3 form-box">
                        	<div class="form-top">
                            </div>
                            <div class="form-bottom">
                            	<h1 style="text-align:center">后台管理系统</h1>
			                    <div id="myForm"  class="login-form">
			                    	<div class="form-group">
			                    		<label class="sr-only" for="form-username">用户名</label>
			                        	<input type="text" id="username" name="username" placeholder="Username..." class="form-username form-control" id="form-username">
			                        </div>
			                        <div class="form-group">
			                        	<label class="sr-only" for="form-password">密码</label>
			                        	<input type="password" id="password" name="password" placeholder="Password..." class="form-password form-control" id="form-password">
			                        </div>
			                        <!-- <div>
			                         	<a href="/qqLogin/qq"><img src="resources/images/qq.jpg" style="width:30px;height:30px;"/></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			                        	<a href="/qqLogin/weixin"><img src="resources/images/weixin.jpg" style="width:30px;height:30px;"/></a>
			                        </div>
			                        <div class="form-group" style="margin-top:10px;">
			                        	<input type="checkbox" name="remember-me"/> &nbsp;&nbsp;<span>记&nbsp;住&nbsp;我</span>
			                        </div> -->
			                        <button id="sub" class="btn" style="width:100%;">登陆</button>
			                    </div>
		                    </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <script src="resources/js/jquery.min.js"></script>
        <script src="resources/js/jquery.backstretch.min.js"></script>
        <script src="resources/js/scripts.js"></script>
        <script src="resources/js/sweetalert2.min.js"></script>

    </body>
    
    <script type="text/javascript">
     $(document).ready(function () {
    	$("#sub").on('click', function() {
    		var username = $("#username").val();
            var password = $("#password").val();
    		$.ajax({
                //几个参数需要注意一下
                 type: "POST",//方法类型
                 url: "./login" ,//url
                 data: {'username':username,'password':password},
                 success: function (result) {
                	 if("0"==result.code){
                		 swal("登录失败",result.msg);
                	 }else{
                		 window.location.href="./main.html";
                	 }
                 },
                 error : function(result) {
                	 if("0"==result.code){
                		 swal(result.msg);
                	 }
                 }
             });
        });
    });
    </script>

</html>